#ifndef _LUCC_DBI_H_
#define _LUCC_DBI_H_


#include "lucc.h"


#define DBI_INT				1
#define DBI_LONG			2
#define DBI_STR16			16
#define DBI_STR32			32
#define DBI_STR64			64
#define DBI_STR128			128
#define DBI_STR256			256
#define DBI_STR512			512
#define DBI_TEXT			8192


typedef struct {
	MYSQL_RES *sql_res;
	MYSQL_ROW sql_row;
	char sql_cmd[1024];
	MYSQL *sql;
	dbpool_t *dbp;
} dbi_t;


extern int dbi_query(dbpool_t *pool, dbi_t *dbi, const char *format, ...);
extern int dbi_fetch_row(dbi_t *dbi);
extern int dbi_fetch_col(dbi_t *dbi, int col, int type, void *value);
extern int dbi_execute(dbpool_t *pool, const char *format, ...);
extern int dbi_query_ints(dbpool_t *pool, int *values, int num, const char *format, ...);
extern int dbi_query_str(dbpool_t *pool, char *value, int type, const char *format, ...);
extern int dbi_free(dbi_t *dbi);


#endif
